package com.codedef.library.repository;

import com.codedef.library.entity.Task;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TaskRepository extends JpaRepository<Task, Integer> {

    @Query(nativeQuery = true,
    value = "SELECT * FROM task WHERE ( type=1 AND date=:tomorrowDateStr ) OR ( type=2 ) OR ( type=3 AND repeat_info LIKE :tomorrowWeekNum ) " +
            "OR ( type=4 AND repeat_info LIKE :tomorrowDayNum  )")
    List<Task> selectTaskComingSoonTask(@Param("tomorrowDateStr") String tomorrowDateStr,
                                        @Param("tomorrowWeekNum") String tomorrowWeekNum,
                                        @Param("tomorrowDayNum") String tomorrowDayNum);

}
